package com.hxzy.research.controller.front;

import com.hxzy.research.form.TeacherForm;
import com.hxzy.research.pojo.TblTeacherResearch;
import com.hxzy.research.service.pageandmanager.AddFrontTeach;
import com.hxzy.research.util.ListSumUtil;
import com.hxzy.research.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping(value = "/front")
public class AddFrontTeachController {
    @Autowired
    AddFrontTeach addFrontTeach;
    @RequestMapping("/addTeacherResearch.go")
    public @ResponseBody
    ResultVo addTeacherResearch(TeacherForm teacherForm, HttpSession session) throws Exception{



        Integer branchId=(Integer) session.getAttribute("branchId");
        TblTeacherResearch teacherResearch=new TblTeacherResearch();
        //向teacherResearch中填充数据
        teacherResearch.setBranchId(branchId);
        teacherResearch.setClassId(teacherForm.getClassId());
        teacherResearch.setCourseId(teacherForm.getCourseId());
        teacherResearch.setTeacherId(teacherForm.getTeacherId());
        teacherResearch.setZyyb(ListSumUtil.getSum(teacherForm.getZyyb()));
        teacherResearch.setJxxg(ListSumUtil.getSum(teacherForm.getJxxg()));
        teacherResearch.setJxtd(ListSumUtil.getSum(teacherForm.getJxtd()));
        teacherResearch.setJy(teacherForm.getJy());
        teacherResearch.setTjDate(new Date());
        //执行添加
        addFrontTeach.AddTeacherResearch(teacherResearch);
        ResultVo resultVo=new ResultVo("200","提交成功");
        return resultVo;
    }
}
